<template>
  <div>
	  <!-- 地址搜索 -->
	  <base-table-select ref="addressRef" v-model="address" :disabled="disabled" placeholder="请选择收货地址" class="my-form_input" :api-obj="deviceObj" :params="params" :table-width="420" :props="deviceProps" @change="change">
	    <template slot="headerBtn">
	  		<div class="addAdress"> 
	  			<el-button type="primary" icon="el-icon-plus" @click="dialogShow=true">新增地址</el-button>
	  		</div>
	  	</template>
	  	<el-table-column prop="consigneeName" label="收货人" width="100" align="center" />
	    <el-table-column prop="consigneePhone" label="联系电话" width="100" align="center" />
	    <el-table-column label="收货地址" min-width="145" align="center">
	      <template slot-scope="{ row }"> <template v-if="row.defaultAddress">【默认】</template>{{ row.detailAddress }} </template>
	    </el-table-column>
	  </base-table-select>
	  <addEditAddress :show="dialogShow" :is-edit-customer="true" :customer-id="param.customerId" :address-obj="addressObj"
	  	@addressChange="dialogShow = false" />
  </div>
</template>

<script>
import { reqCustomerAddress } from '@/api/module/customer.js'
import addEditAddress from '@/components/dialog/add-edit-address.vue'
export default {
	components: {
		addEditAddress
	},
  props: {
    disabled: {
      type: Boolean,
      default: false
    },
    param: {
      type: Object,
      default: () => {
        return {}
      }
    },
    data: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
	  dialogShow:false,
	  addressObj: {},					
      address: {},
      deviceObj: reqCustomerAddress, // 请求接口
      deviceProps: {
        label: 'detailAddress',
        value: 'id',
        keyword: 'keyWord',
        page: 'page',
        pageSize: 'size'
      },
      params: {
        valid: true,
        status: 'PASSED'
      }
    }
  },
  watch: {
    param: {
      handler() {
        Object.assign(this.params, this.param)
      },
      deep: true,
      immediate: true
    },
    data: {
      handler(val) {
        this.address = Object.assign({}, this.address, val)
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    change() {
      this.$emit('change', this.address)
    },
    clear() {
      this.address = {}
    },
    getData() {
      this.$refs.addressRef.getData()
    },
	add(){
		
	},
	addAddress(){
		
	},
	
  }
}
</script>

<style lang="scss" scoped>
	.addAdress{
		text-align: right;
		margin-bottom: 5px;
	}
</style>
